<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>props</h2>
      <!-- 如果传递的是数字，或者布尔值，或者数组对象等，需要加冒号 -->
      <!-- 加了冒号就变成js表达式 -->
      <!-- <child
        msg-str="hello"
        :count-num="true"
        :id="post.id"
        :title="post.title"
      ></child> -->
      <child msg-str="hello" :count-num="true" v-bind="post"></child>
    </div>

    <script src="./Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      const Child = {
        // 数组的方式接收props
        // props: ["msg"],

        // 对象的方式接收props，可以让我们约定的props的数据类型
        props: {
          msgStr: String,
          countNum: Boolean,
          id: Number,
          title: String,
        },
        template: `
          <div>child组件 - {{ msgStr }} - {{ countNum }} - {{ id }} - {{ title }}</div>
        `,
      };

      createApp({
        data() {
          return {
            // count: 5,
            post: {
              id: 1,
              title: "My Journey with Vue",
            },
          };
        },
        components: {
          Child,
        },
      }).mount("#app");
    </script>
  </body>
</html>
